package com.mobilesafe.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mobilesafe.domain.ContactInfo;
import com.mobilesafe.ui.SelectContactActivity;

public class SelectContactAdapter extends BaseAdapter {
	private List<ContactInfo> infos;
	private LinearLayout ll;
	private Context context;
	private TextView tv_name;
	private TextView tv_phone;
	
	public SelectContactAdapter(List<ContactInfo> infos, Context context) {
		super();
		this.infos = infos;
		this.context = context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return infos.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return infos.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ContactInfo info = infos.get(position);
		ll = new LinearLayout(context);
		ll.setOrientation(LinearLayout.VERTICAL);
		tv_name = new TextView(context);
		tv_name.setText("姓名"+ info.getName());
		tv_phone = new TextView(context);
		tv_phone.setText("联系电话"+ info.getPhone());
		ll.addView(tv_name);
		ll.addView(tv_phone);
		
		return ll;
	}

}
